package com.ttg.web.controller.common;

import com.ttg.common.entities.BaseResult;
import com.ttg.common.utils.RequestParamsManager;
import com.ttg.model.dto.TagHisDTO;
import com.ttg.web.service.TagHisService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * 标签历史表控制器
 */
@RestController
@RequestMapping("/tagHis")
public class TagHisController {
    @Autowired
    private TagHisService tagHisService;
    @ApiOperation("获取标签统计计算分页")
    @RequestMapping("/tagHisPage")
    public BaseResult tagHisPage(@RequestBody(required = false) String data){
        TagHisDTO reqDto = RequestParamsManager.transformRequestParam(data, TagHisDTO.class);
        return BaseResult.success(tagHisService.tagHisPage(reqDto));
    }

    @ApiOperation("统计导出")
    @RequestMapping("/export")
    public void export(@RequestBody(required = false) String data, HttpServletResponse response){
        TagHisDTO reqDto = RequestParamsManager.transformRequestParam(data, TagHisDTO.class);
        tagHisService.export(reqDto, response);
    }
}